package dre.sample.actions.dispatch;

import java.util.ArrayList;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;


import dre.sample.beans.InformationBean;
import dre.sample.forms.InformationDispatchForm;

public class AllDispatchAction extends DispatchAction{
	
	private String link = "success";


	public ActionForward processCreate(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {
			
		link="create";
		return mapping.findForward(link);
	}
		
	public ActionForward processEdit(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {
			
		InformationDispatchForm frm = (InformationDispatchForm) form;
		int i = 0;
		frm.setEmployeeId("String"+i);
		frm.setFirstName(Integer.toString(i));
		frm.setLastName(Integer.toString(i));
		link="edit";
		return mapping.findForward(link);
	}
	
	
	public ActionForward processViewSeat(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response)
			throws Exception {
				
			InformationDispatchForm frm = (InformationDispatchForm) form;
			ArrayList ar = new ArrayList();
			for (int i=0;i<5;i++) {
				InformationBean ib = new InformationBean();
				ib.setEmployeeId("employee" +i);
				ib.setFirstName("firstname" +i);
				ib.setLastName("lastname"+i);
				ar.add(ib);
			}
			frm.setListVal(ar);
			link="list";
			return mapping.findForward(link);
		}
}
